<template>
  <div class="AlarmQuery">
    <div class="return-backgorund" v-show="showReturn">
      <el-button type="text" size="mini" @click="returnTopViews" class="return-button">返回</el-button>
    </div>
    <div class="filter">
      <el-form ref="form" label-width="90px">
        <el-form-item label="设备区域:">
          <div class="el_consist" :style="{width: itemWidth + 'px', height: devicesAreas.height}">
            <el-checkbox
              class="allCheckBox"
              :label="0"
              name="type"
              :indeterminate="devicesAreas.checkArea.length > 0 && devicesAreas.checkArea.length < devicesAreas.areas.length"
              v-model="devicesAreas.checkAll"
              @change="handle_d_a_CheckAllChange"
            >全部</el-checkbox>
            <el-checkbox-group v-model="devicesAreas.checkArea" @change="handle_d_a_CheckChange">
              <el-checkbox
                v-for="item in devicesAreas.areas"
                :key="item.id"
                :label="item.id"
                name="type"
              >{{item.name}}</el-checkbox>
            </el-checkbox-group>
          </div>
          <el-checkbox
            :label="0"
            name="type"
            v-show="itemCount < this.devicesAreas.areas.length + 1"
            @change="handle_d_a_lookMore"
          >查看更多</el-checkbox>
        </el-form-item>
        <el-form-item label="设备类型:">
          <div class="el_consist" :style="{width: itemWidth + 'px', height: devicesType.height}">
            <el-checkbox
              class="allCheckBox"
              :label="0"
              name="type"
              :indeterminate="devicesType.checkType.length > 0 && devicesType.checkType.length < devicesType.types.length"
              v-model="devicesType.checkAll"
              @change="handle_d_t_CheckAllChange"
            >全部</el-checkbox>
            <el-checkbox-group v-model="devicesType.checkType" @change="handle_d_t_CheckChange">
              <el-checkbox
                v-for="item in devicesType.types"
                :key="item.id"
                :label="item.id"
                name="type"
              >{{item.displayName}}</el-checkbox>
            </el-checkbox-group>
          </div>
          <el-checkbox
            :label="0"
            name="type"
            v-show="itemCount < this.devicesType.types.length + 1"
            @change="handle_d_t_lookMore"
          >查看更多</el-checkbox>
        </el-form-item>
        <el-form-item label="识别类型:">
          <div
            class="el_consist"
            :style="{width: itemWidth + 'px', height: recognitionType.height}"
          >
            <el-checkbox
              class="allCheckBox"
              :label="0"
              name="type"
              :indeterminate="recognitionType.checkType.length > 0 && recognitionType.checkType.length < recognitionType.types.length"
              v-model="recognitionType.checkAll"
              @change="handle_r_t_CheckAllChange"
            >全部</el-checkbox>
            <el-checkbox-group v-model="recognitionType.checkType" @change="handle_r_t_CheckChange">
              <el-checkbox
                v-for="item in recognitionType.types"
                :key="item.id"
                :label="item.id"
                name="type"
              >{{item.name}}</el-checkbox>
            </el-checkbox-group>
          </div>
          <el-checkbox
            :label="0"
            name="type"
            v-show="itemCount < this.recognitionType.types.length + 1"
            @change="handle_r_t_lookMore"
          >查看更多</el-checkbox>
        </el-form-item>
        <el-form-item label="告警等级:">
          <div class="el_consist" :style="{width: itemWidth + 'px', height: alarmLevel.height}">
            <el-checkbox
              class="allCheckBox"
              :label="0"
              name="type"
              :indeterminate="alarmLevel.checkLevel.length > 0 && alarmLevel.checkLevel.length < alarmLevel.levels.length"
              v-model="alarmLevel.checkAll"
              @change="handle_a_l_CheckAllChange"
            >全部</el-checkbox>
            <el-checkbox-group v-model="alarmLevel.checkLevel" @change="handle_a_l_CheckChange">
              <el-checkbox
                v-for="item in alarmLevel.levels"
                :key="item.value"
                :label="item.value"
                name="type"
              >{{item.text}}</el-checkbox>
            </el-checkbox-group>
          </div>
          <el-checkbox
            :label="0"
            name="type"
            v-show="itemCount < alarmLevel.levels.length + 1"
            @change="handle_a_l_lookMore"
          >查看更多</el-checkbox>
        </el-form-item>
        <el-form-item label="点位类型:">
          <div class="el_consist" :style="{width: itemWidth + 'px', height: pointType.height}">
            <el-checkbox
              class="allCheckBox"
              :label="0"
              name="type"
              :indeterminate="pointType.checkType.length > 0 && pointType.checkType.length < pointType.types.length"
              v-model="pointType.checkAll"
              @change="handle_p_t_CheckAllChange"
            >全部</el-checkbox>
            <el-checkbox-group v-model="pointType.checkType" @change="handle_p_t_CheckChange">
              <el-checkbox
                v-for="item in pointType.types"
                :key="item.value"
                :label="item.value"
                name="type"
              >{{item.text}}</el-checkbox>
            </el-checkbox-group>
          </div>
          <el-checkbox
            :label="0"
            name="type"
            v-show="itemCount < pointType.types.length + 1"
            @change="handle_p_t_lookMore"
          >查看更多</el-checkbox>
        </el-form-item>
        <div class="operation">
          <el-form-item label="开始时间:">
            <el-date-picker
              v-model="recordHistory.startTime"
              type="date"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd"
              :picker-options="startPickerOptions"
            ></el-date-picker>
          </el-form-item>
          <el-form-item label="结束时间:">
            <el-date-picker
              v-model="recordHistory.endTime"
              type="date"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd"
              :picker-options="endPickerOptions"
            ></el-date-picker>
          </el-form-item>
          <el-form-item label>
            <el-radio-group
              v-model="recordHistory.checkStatus"
              @change="inspection_status_change_click"
            >
              <el-radio label="1">已审核</el-radio>
              <el-radio label="0">未审核</el-radio>
            </el-radio-group>
          </el-form-item>
          <!-- <el-form-item label="类型:" label-width="50px">
            <el-select size="mini" clearable placeholder="请选择" v-model="checkInspectionType">
              <el-option
                v-for="item in inspectionType"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>-->
          <el-button class="but-query" type="text" size="medium" @click="query_data">
            <i class="query-icon"></i>查询
          </el-button>
          <el-button class="but-reset" type="text" size="medium" @click="reset_data">
            <i class="reset-icon"></i>重置
          </el-button>
          <el-button class="but-export" type="text" size="medium" @click="exportExcel">
            <i class="export-icon"></i>导出
          </el-button>
          <el-button
            class="but-confirm"
            type="text"
            size="medium"
            @click="centerDialogVisible = true"
            :disabled="this.multipleSelection.length <= 0"
          >
            <i class="confirm-icon"></i>批量确认
          </el-button>
        </div>
      </el-form>
    </div>
    <div class="content">
      <div class="content-left">
        <div class="left-head">设备树</div>
        <div class="tree-list">
          <Tree-List
            ref="TreeList"
            :data="allDeviceTreeList"
            :showIcon="true"
            :showState="true"
            @vtl_dataChange="treeDataChange"
            :activedDisabled="true"
          ></Tree-List>
        </div>
      </div>
      <div class="content-right">
        <div class="right-head">设备告警查询确认</div>
        <div class="content-list">
          <el-table
            ref="alarmQueryTable"
            :data="tableData"
            border
            stripe
            size="mini"
            class="el-table-redefine"
            style="width: 100%;"
            height="100%"
            :row-class-name="tableRowClassName"
            @row-click="onRowClick"
            @row-dblclick="onRowDoubleClick"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
            <el-table-column type="selection" align="center" width="55"></el-table-column>
            <el-table-column prop="reconType.name" label="识别类型"></el-table-column>
            <el-table-column prop="point.name" label="点位名称"></el-table-column>
            <el-table-column prop label="识别结果">
              <template slot-scope="scope">
                <span>{{scope.row ? matchArrayContentStr(scope.row.pointHistory.value, meterReadingDealWith) : "未知"}}</span>
              </template>
            </el-table-column>
            <el-table-column width="100px" label="审核结果">
              <template slot-scope="scope">
                <span>{{scope.row.checkStatus == 0 ? "未审核" : "已审核"}}</span>
              </template>
            </el-table-column>
            <el-table-column label="告警等级">
              <template slot-scope="scope">
                <span>{{scope.row ? matchArrayContentStr(scope.row.alarmLevel, alarmLevel.levels) : "未知"}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="alarmType.name" label="告警类型"></el-table-column>
            <el-table-column prop="checkTime" label="告警时间"></el-table-column>
            <el-table-column label="采集信息">
              <template slot-scope="scope">
                <el-button
                  type="text"
                  size="mini"
                  class="picture-button"
                  @click.stop="showImage(scope.row.pointHistory.flirPic)"
                  :hidden="!(scope.row.point && (scope.row.point.saveTypeId === 1 || !scope.row.point.saveTypeId === 4))"
                >红外图片</el-button>
                <el-button
                  type="text"
                  size="mini"
                  class="picture-button"
                  @click.stop="showImage(scope.row.pointHistory.cameraPic)"
                  :hidden="!(scope.row.point && (scope.row.point.saveTypeId === 2 || !scope.row.point.saveTypeId === 4))"
                >可见光图片</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="pagination-area">
          <el-pagination
            layout="total, sizes, prev, pager, next, jumper, slot"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[20, 50, 100, 300]"
            :page-size="recordHistory.size"
            :current-page="recordHistory.page"
            :total="tansksTotal"
          >
            <el-button type="text" size="mini">前往</el-button>
          </el-pagination>
        </div>
      </div>
    </div>
    <DialogAlarm
      ref="DialogAlarm"
      dialogTitle="告警确认"
      :data="tableData"
      :row="selectedRow"
      @change="confirm_finish_click"
    ></DialogAlarm>
    <el-dialog
      class="confirm_dialog"
      title="提示"
      :visible.sync="centerDialogVisible"
      width="20%"
      left
    >
      <div class="dialog-body">
        <div class="body-title">是否批量确认</div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="centerDialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogConfirm()">确 定</el-button>
        </span>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {
  devicesAreas,
  devicesTypesList,
  reconTypesList,
  pointAlarmRecordList,
  pointsTree,
  pointHistoryRelationPoint,
  alarmTypesList,
  pointAlarmRecordBatchConfirm,
  postOperationLogs
} from "@/api/apiManagement";
import {
  matchArrayContent,
  AlarmLevel,
  PointType,
  MeterReadingDealWith
} from "@/utils/constant";
import DialogAlarm from "./components/DialogAlarm";
import { formatJson } from "@/utils";
import {
  dateToDateStr,
  getDateTopMonth,
  dateToDateWithToSecondStr
} from "@/utils/utilsMethod";
import { throws } from "assert";
import Viewer from "viewerjs";
import "viewerjs/dist/viewer.css";
import TreeList from "@/components/TreeList";

export default {
  components: { DialogAlarm, TreeList },

  data() {
    return {
      robot_id: null,
      showReturn: this.$route.query.showReturn,
      taskHistoryId: this.$route.query.taskHistoryId,
      itemCount: 5,
      itemWidth: 220 * 5,
      devicesAreas: {
        areas: [],
        checkArea: [],
        checkAll: false,
        height: "31px"
      },
      devicesType: {
        types: [],
        checkType: [],
        checkAll: false,
        height: "31px"
      },
      recognitionType: {
        types: [],
        checkType: [],
        checkAll: false,
        height: "31px"
      },
      alarmLevel: {
        levels: [],
        checkLevel: [],
        checkAll: false,
        height: "31px"
      },
      pointType: {
        types: PointType,
        checkType: [],
        checkAll: false,
        height: "31px"
      },
      topCheckTreeId: "",
      topCheckAlarmLevel: "",
      allDeviceTreeList: [],
      recordHistory: {
        page: 0,
        size: 20,
        robotId: 1,
        startTime: "",
        endTime: "",
        checkStatus: "0",
        alarmLevel: "",
        pointIds: ""
      },
      tableData: [],
      tansksTotal: 0,
      dialogVisible: false,
      alarmData: {
        singleCheckAlarmNum: -1,
        singleCheckAlarm: {},
        checkAlarm: [],
        relationPoint: []
      },
      multipleSelection: [],
      selectedRow: 0,
      centerDialogVisible: false,

      // inspectionType: [{ value: 0, label: "点" }, { value: 1, label: "面" }],
      // checkInspectionType: 0,
      startPickerOptions: {
        disabledDate: time => {
          let endTime =
            this.recordHistory.endTime === null
              ? ""
              : this.recordHistory.endTime;
          return (
            time.getTime() > new Date(endTime).getTime() ||
            time.getTime() > Date.now() - 8.64e6
          );
        }
      },
      endPickerOptions: {
        disabledDate: time => {
          let startTime =
            this.recordHistory.startTime === null
              ? ""
              : this.recordHistory.startTime;
          return (
            time.getTime() <
              new Date(startTime).getTime() - 8 * 60 * 60 * 1000 ||
            time.getTime() > Date.now() - 8.64e6
          ); //如果没有后面的-8.64e6就是不可以选择今天的   减去一天的时间代表可以选择同一天
        }
      },
      meterReadingDealWith: MeterReadingDealWith
    };
  },
  created() {
    this.robot_id = localStorage.getItem("ydRobot_id");
    this.recordHistory.robotId = this.robot_id;
    this.recordHistory.startTime = dateToDateStr(getDateTopMonth(new Date()));
    this.recordHistory.endTime = dateToDateStr(new Date());
    this.alarmLevel.levels = AlarmLevel.slice(1);
  },
  mounted() {
    this.itemCount = Math.floor((document.body.clientWidth - 100) / 220 - 1);
    this.itemCount = this.itemCount === 0 ? 1 : this.itemCount;
    this.itemWidth = this.itemCount * 220;
    // 监听窗口大小
    window.onresize = () => {
      return (() => {
        this.itemCount = Math.floor(
          (document.body.clientWidth - 100) / 220 - 1
        );
        this.itemCount = this.itemCount === 0 ? 1 : this.itemCount;
        this.itemWidth = this.itemCount * 220;
      })();
    };
    // 设备区域
    this.alerm_GetDevicesAreas();
    // 设备类型
    this.alerm_GetDevicesType();
    // 识别类型
    this.alerm_GetRecognitionType();
    // 点位树
    this.getPointsTree();
  },
  methods: {
    // 设备区域
    alerm_GetDevicesAreas() {
      devicesAreas()
        .then(response => {
          if (response) {
            this.devicesAreas.areas = response;
          }
        })
        .catch(() => {});
    },
    // 设备类型
    alerm_GetDevicesType() {
      devicesTypesList()
        .then(response => {
          if (response) {
            this.devicesType.types = response.list.filter(item => {
              return parseInt(item.name) >= 2000;
            });
          }
        })
        .catch(() => {});
    },
    // 设备区域
    alerm_GetRecognitionType() {
      reconTypesList()
        .then(response => {
          if (response) {
            this.recognitionType.types = response.list;
          }
        })
        .catch(() => {});
    },
    // 告警记录列表
    alerm_PointAlarmRecord() {
      this.recordHistory.startTime =
        this.recordHistory.startTime == null
          ? ""
          : this.recordHistory.startTime;
      this.recordHistory.endTime =
        this.recordHistory.endTime == null
          ? ""
          : this.recordHistory.endTime.length <= 10 &&
            this.recordHistory.endTime.length != 0
          ? this.recordHistory.endTime + " 24:00:00"
          : this.recordHistory.endTime;

      var parm = {
        page: this.recordHistory.page,
        size: this.recordHistory.size,
        robotId: this.recordHistory.robotId,
        startTime: this.recordHistory.startTime,
        endTime: this.recordHistory.endTime,
        checkStatus: this.recordHistory.checkStatus,
        alarmLevel: this.recordHistory.alarmLevel,
        pointIds: this.recordHistory.pointIds
        // pointType: this.checkInspectionType
      };
      if (this.taskHistoryId) {
        parm["taskHistoryId"] = this.taskHistoryId;
      }
      pointAlarmRecordList(parm)
        .then(response => {
          if (response) {
            this.tansksTotal = response.total;
            this.tableData = response.list;
          }
        })
        .catch(() => {});
    },
    // 点位树
    getPointsTree() {
      pointsTree()
        .then(response => {
          if (response) {
            this.allDeviceTreeList = response;
            this.treeDataReorganization();
          }
        })
        .catch(() => {});
    },
    // 告警类型
    alerm_GetAlarmType() {
      this.alarmTypes = [];
      alarmTypesList()
        .then(response => {
          if (response) {
            this.alarmTypes = response.list;
          }
        })
        .catch(() => {});
    },
    // 点位告警记录模块 batchConfirm
    alerm_putPointAlarmBatchConfirm() {
      if (this.multipleSelection.length <= 0) return;
      let requestData = [];
      this.multipleSelection.forEach(function(el, index) {
        requestData.push(el.id);
      });
      pointAlarmRecordBatchConfirm({ ids: requestData.join(",") })
        .then(response => {
          this.multipleSelection.forEach(item => {
            this.setOperationLogs(
              "审核-" + item.task.name + "任务-" + item.point.name + "的结果"
            );
          });

          this.recordHistory.checkStatus = "1";
          this.$message({
            message: "操作成功",
            type: "success"
          });
          this.alerm_PointAlarmRecord();
        })
        .catch(() => {});
    },
    // =================== 以下是多选区域的选中事件 ==================== //
    handle_d_a_CheckAllChange(val) {
      this.devicesAreas.checkArea = val
        ? this.devicesAreas.areas.map(item => {
            return item.id;
          })
        : [];
      this.treeDataReorganization();
    },
    handle_d_a_CheckChange(val) {
      this.devicesAreas.checkAll =
        this.devicesAreas.areas.length === val.length;
      this.treeDataReorganization();
    },
    handle_d_a_lookMore(val) {
      this.devicesAreas.height = val ? "auto" : "31px";
    },
    handle_d_t_CheckAllChange(val) {
      this.devicesType.checkType = val
        ? this.devicesType.types.map(item => {
            return item.id;
          })
        : [];
      this.treeDataReorganization();
    },
    handle_d_t_CheckChange(val) {
      this.devicesType.checkAll = this.devicesType.types.length === val.length;
      this.treeDataReorganization();
    },
    handle_d_t_lookMore(val) {
      this.devicesType.height = val ? "auto" : "31px";
    },
    handle_r_t_CheckAllChange(val) {
      this.recognitionType.checkType = val
        ? this.recognitionType.types.map(item => {
            return item.id;
          })
        : [];
      this.treeDataReorganization();
    },
    handle_r_t_CheckChange(val) {
      this.recognitionType.checkAll =
        this.recognitionType.types.length === val.length;
      this.treeDataReorganization();
    },
    handle_r_t_lookMore(val) {
      this.recognitionType.height = val ? "auto" : "31px";
    },
    handle_a_l_CheckAllChange(val) {
      this.alarmLevel.checkLevel = val
        ? this.alarmLevel.levels.map(item => {
            return item.value;
          })
        : [];
      // 告警等级因为不需要筛选树所以不要下面这句
      // this.treeDataReorganization();
    },
    handle_a_l_CheckChange(val) {
      this.alarmLevel.checkAll = this.alarmLevel.levels.length === val.length;
      // 告警等级因为不需要筛选树所以不要下面这句
      // this.treeDataReorganization();
    },
    handle_a_l_lookMore(val) {
      this.alarmLevel.height = val ? "auto" : "31px";
    },
    handle_p_t_CheckAllChange(val) {
      this.pointType.checkType = val
        ? this.pointType.types.map(item => {
            return item.value;
          })
        : [];
      this.treeDataReorganization();
    },
    handle_p_t_CheckChange(val) {
      this.pointType.checkAll = this.pointType.types.length === val.length;
      this.treeDataReorganization();
    },
    handle_p_t_lookMore(val) {
      this.pointType.height = val ? "auto" : "31px";
    },
    // ==================  中间按钮区域 ======================== //
    inspection_status_change_click(val) {
      this.recordHistory.checkStatus = val;
    },
    query_data() {
      var checkTree = this.$refs.TreeList.vtl_getCurrentNode();
      if (checkTree && checkTree.leaf == true) {
        if (
          typeof checkTree.id === "string" &&
          checkTree.id.indexOf("point_") != -1
        ) {
          let index = checkTree.id.lastIndexOf("_");
          let slice = checkTree.id.substring(index + 1);
          this.recordHistory.pointIds = slice;
        }
      } else {
        let pointIdsArr = [];
        var tempList = this.$refs.TreeList.vtl_getLeafNodesId();
        if (checkTree) {
          tempList = this.$refs.TreeList.vtl_getParentNodeLeafNodesId(
            checkTree
          );
        }
        pointIdsArr = tempList.map(item => {
          if (typeof item === "string" && item.indexOf("point_") != -1) {
            let index = item.lastIndexOf("_");
            let slice = item.substring(index + 1);
            return slice;
          }
          return "";
        });
        this.recordHistory.pointIds = pointIdsArr.join(",");
      }
      if (this.topCheckTreeId != this.recordHistory.pointIds) {
        this.recordHistory.page = 0;
        this.recordHistory.size = 20;
        this.tableData = [];
      }
      this.topCheckTreeId = this.recordHistory.pointIds;

      this.recordHistory.alarmLevel = this.alarmLevel.checkLevel.join(",");
      if (this.topCheckAlarmLevel != this.recordHistory.alarmLevel) {
        this.recordHistory.page = 0;
        this.recordHistory.size = 20;
        this.tableData = [];
      }
      this.topCheckAlarmLevel = this.recordHistory.alarmLevel;

      this.alerm_PointAlarmRecord();
    },
    reset_data() {
      this.devicesAreas.checkArea = [];
      this.devicesAreas.checkAll = false;
      this.devicesType.checkType = [];
      this.devicesType.checkAll = false;
      this.recognitionType.checkType = [];
      this.recognitionType.checkAll = false;
      this.alarmLevel.checkLevel = [];
      this.alarmLevel.checkAll = false;
      this.topCheckAlarmLevel = "";
      this.topCheckTreeId = "";
      this.treeDataReorganization();

      this.multipleSelection = [];
      this.recordHistory.page = 0;
      this.recordHistory.size = 20;
      this.recordHistory.startTime = dateToDateStr(getDateTopMonth(new Date()));
      this.recordHistory.endTime = dateToDateStr(new Date());
      this.recordHistory.checkStatus = "0";
      this.$refs.TreeList.vtl_setCurrentNodeId({});
      this.recordHistory.pointIds = this.getAllPointIds();

      this.alerm_PointAlarmRecord();
    },
    exportExcel() {
      if (this.multipleSelection.length > 0) {
        require.ensure([], () => {
          const { export_json_to_excel } = require("vendor/Export2Excel");
          const tHeader = [
            "识别类型",
            "点位名称",
            "识别结果",
            "告警等级",
            "告警类型",
            "告警时间",
            "采集信息"
          ];
          const filterVal = [
            "reconType.name",
            "point.name",
            "pointHistory.value",
            "alarmLevel",
            "alarmType.name",
            "checkTime",
            "picUrl"
          ];
          let temp = JSON.parse(JSON.stringify(this.multipleSelection));
          const data = formatJson(filterVal, this.formatAlartType(temp));
          export_json_to_excel(
            tHeader,
            data,
            "设备告警查询确认表" + dateToDateWithToSecondStr(new Date())
          );
        });
      } else {
        this.$message({
          message: "请选择数据"
        });
      }
    },
    formatAlartType(data) {
      let array = data.slice(0);
      array.forEach((item, index) => {
        item["alarmLevel"] = matchArrayContent(
          item["alarmLevel"],
          this.alarmLevel.levels
        );
        var picUrl =
          item.point &&
          (item.point.saveTypeId === 1 || item.point.saveTypeId === 4)
            ? item.pointHistory.flirPic
            : item.point.saveTypeId === 2
            ? item.pointHistory.cameraPic
            : "";
        var picType =
          item.point &&
          (item.point.saveTypeId === 1 || item.point.saveTypeId === 4)
            ? "红外图片"
            : item.point.saveTypeId === 2
            ? "可见光图片"
            : "";
        item["picUrl"] = picType + "_" + picUrl;
        if (item.pointHistory) {
          item.pointHistory.value = matchArrayContent(item.pointHistory.value, MeterReadingDealWith)
        }
      });
      return array;
    },
    dialogConfirm() {
      this.alerm_putPointAlarmBatchConfirm();
      this.centerDialogVisible = false;
    },
    // =============== 树的点击 ================= //
    getAlarmLevelClassName(value) {
      if (value === 0) {
        return "normal";
      }
      if (value === 1) {
        return "warning";
      }
      if (value === 2) {
        return "general-alarm";
      }
      if (value === 3) {
        return "serious-alarm";
      }
      if (value === 4) {
        return "danger-alarm";
      }
    },
    // ========== 点击事件 ========== //
    handleSizeChange(val) {
      this.recordHistory.size = val;
      this.alerm_PointAlarmRecord();
    },
    handleCurrentChange(val) {
      this.recordHistory.page = val;
      this.alerm_PointAlarmRecord();
    },
    tableRowClassName({ row, rowIndex }) {
      row.index = rowIndex;
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    onRowClick(row, column, event) {
      this.$refs.alarmQueryTable.toggleRowSelection(row);
    },
    onRowDoubleClick(row, column, event) {
      this.selectedRow = row.index;
      this.$refs.DialogAlarm.isShowDia(true);
    },
    showImage(val) {
      var image = new Image();
      image.src = val;
      var viewer = new Viewer(image, {
        navbar: false,
        title: false,
        minHeight: "20px",
        hidden: function() {
          viewer.destroy();
        }
      });
      viewer.show();
    },
    confirm_finish_click() {
      this.alerm_PointAlarmRecord();
    },
    // =============== 数据处理的方法 =============== //
    // 树状数据重组
    treeDataReorganization() {
      this.$refs.TreeList.vtl_setCurrentNodeId({});
      this.$refs.TreeList.vtl_nodesFilter({
        deviceAreasList: this.devicesAreas.checkArea,
        deviceTypeList: this.devicesType.checkType,
        recognitionTypeList: this.recognitionType.checkType,
        pointType: this.pointType.checkType,
        meterTypeList: [],
        deviceAppearanceTypeList: [],
        useList: []
      });
    },
    // 匹配类型返回
    matchArrayContentStr(val, array) {
      return matchArrayContent(val, array);
    },
    // 添加日志管理
    setOperationLogs(content) {
      var parm = {
        content: content,
        deviceId: localStorage.getItem("ydRobot_device_id"),
        type: 0
      };
      postOperationLogs(parm)
        .then(response => {})
        .catch(() => {});
    },
    returnTopViews() {
      this.$router.push({
        path: "/resultsConfirm/inspection-task-audit"
      });
    },
    treeDataChange(tree, list, obj) {
      this.recordHistory.pointIds = this.getAllPointIds();
      this.alerm_PointAlarmRecord();
    },
    getAllPointIds() {
      var temp = this.$refs.TreeList.vtl_getLeafNodesId().map(item => {
        if (typeof item === "string" && item.indexOf("point_") != -1) {
          let index = item.lastIndexOf("_");
          let slice = item.substring(index + 1);
          return slice;
        }
        return "";
      });
      return temp.join(",");
    }
  }
};
</script>

<style>
.AlarmQuery .filter .el-form-item {
  margin-top: 0;
  margin-bottom: 3px;
}
.AlarmQuery .filter .el-form-item .el_consist {
  float: left;
  overflow: hidden;
}
.AlarmQuery .filter .el-form-item__label {
  font-size: 13px;
  line-height: 26px;
}
.AlarmQuery .filter .el-form-item__content {
  font-size: 13px;
  line-height: 26px;
}
.AlarmQuery .filter .el-radio__label {
  font-size: 13px;
}
.AlarmQuery .filter .el-checkbox {
  font-size: 13px;
}
.AlarmQuery .filter .el-checkbox__label {
  font-size: 13px;
}
.AlarmQuery .filter .el-radio {
  /* width: 86px; */
  margin-left: 15px;
}
.AlarmQuery .filter .el-radio + .el-radio {
  margin-left: 5px;
}
.AlarmQuery .filter .el-checkbox {
  width: 210px;
  margin-left: 10px;
}
.AlarmQuery .filter .el-checkbox + .el-checkbox {
  margin-left: 10px;
}
.AlarmQuery .content-left .custom-tree-node span {
  font-size: 13px;
}
.AlarmQuery .folder {
  width: 13px;
  height: 13px;
  margin-top: 3px;
  /* background-color: rgb(10, 158, 80); */
  background-image: url(../../../static/resources/images/folder.png);
  background-size: 100% 100%;
  float: left;
}
.AlarmQuery .file {
  width: 13px;
  height: 13px;
  margin-top: 3px;
  /* background-color: rgb(255, 0, 0); */
  background-image: url(../../../static/resources/images/file.png);
  background-size: 100% 100%;
  float: left;
}

.AlarmQuery .alarm {
  width: 12px;
  height: 13px;
  margin: 3px 2px 0 2px;
  float: left;
}
.AlarmQuery .normal {
  background-color: rgb(50, 150, 50);
}
.AlarmQuery .warning {
  background-color: rgb(0, 0, 255);
}
.AlarmQuery .general-alarm {
  background-color: rgb(255, 255, 0);
}
.AlarmQuery .serious-alarm {
  background-color: rgb(255, 128, 10);
}
.AlarmQuery .danger-alarm {
  background-color: rgb(155, 0, 0);
}

.AlarmQuery {
  width: 100%;
  height: 100%;
  display: flex;
  flex-flow: column;
}
.AlarmQuery .filter {
  position: relative;
  width: 100%;
  /* height: 65px; */
  background-color: #eeeeee;
}
.AlarmQuery .allCheckBox {
  float: left;
}
.AlarmQuery .operation {
  width: 100%;
  height: 30px;
  background: linear-gradient(
    rgb(227, 242, 238),
    rgb(202, 231, 238)
  ); /* 标准的语法 */
  border-top: 1px solid rgb(202, 231, 238);
}

.AlarmQuery .operation .el-form-item {
  margin-top: 1px;
  margin-bottom: 0;
  float: left;
}
.AlarmQuery .operation .el-form-item__content {
  width: 210px;
  margin-left: 5px !important;
}
.AlarmQuery .operation .el-form-item__content {
  /* width: 200px; */
  margin-left: 5px !important;
  line-height: 26px;
  float: left;
}
.AlarmQuery .operation .el-date-editor.el-input {
  width: 200px;
}
.AlarmQuery .operation .el-input__inner {
  height: 26px;
  line-height: 26px;
}
.AlarmQuery .operation .el-input__icon {
  line-height: 26px;
}
.AlarmQuery .but-query,
.AlarmQuery .but-reset,
.AlarmQuery .but-export,
.AlarmQuery .but-confirm {
  height: 30px;
  margin-left: 20px;
  margin-right: 10px;
  padding: 0;
  font-size: 13px;
  color: #000;
  float: left;
}
.AlarmQuery .query-icon {
  width: 14px;
  height: 14px;
  margin-right: 3px;
  background-image: url(../../../static/resources/images/query.png);
  background-size: 100% 100%;
  float: left;
}
.AlarmQuery .reset-icon {
  width: 14px;
  height: 14px;
  margin-right: 3px;
  background-image: url(../../../static/resources/images/reset_a.png);
  background-size: 100% 100%;
  float: left;
}
.AlarmQuery .export-icon {
  width: 14px;
  height: 14px;
  margin-right: 3px;
  background-image: url(../../../static/resources/images/export.png);
  background-size: 100% 100%;
  float: left;
}
.AlarmQuery .confirm-icon {
  width: 14px;
  height: 14px;
  margin-right: 3px;
  background-image: url(../../../static/resources/images/confirm.png);
  background-size: 100% 100%;
  float: left;
}

.AlarmQuery .content {
  width: 100%;
  min-height: 360px;
  flex-grow: 1;
}
.AlarmQuery .content-left {
  position: relative;
  width: 300px;
  height: 100%;
  /* background-color: #eeeeee; */
  background-color: #fff;
  border-right: 1px solid rgb(202, 231, 238);
  float: left;
}
.AlarmQuery .content-right {
  position: relative;
  /* width: 100%; */
  width: calc(100% - 300px);
  height: 100%;
  /* margin-left: 300px; */
  /* padding: 0 0 0 10px; */
  border-left: 1px solid rgb(202, 231, 238);
  float: left;
}
.AlarmQuery .left-head {
  width: 100%;
  height: 27px;
  padding: 0 5px;
  line-height: 27px;
  font-size: 13px;
  background: linear-gradient(
    rgb(227, 242, 238),
    rgb(202, 231, 238)
  ); /* 标准的语法 */
}
.AlarmQuery .tree-list {
  position: absolute;
  width: 100%;
  height: calc(100% - 27px);
  overflow: auto;
}
.AlarmQuery .right-head {
  width: 100%;
  height: 27px;
  padding: 0 5px;
  line-height: 27px;
  font-size: 13px;
  background: linear-gradient(
    rgb(227, 242, 238),
    rgb(202, 231, 238)
  ); /* 标准的语法 */
}

.AlarmQuery .content-list {
  position: absolute;
  width: 100%;
  height: calc(100% - 59px);
  /* overflow: auto; */
}

.AlarmQuery .content-list .picture-button {
  margin-left: 0px;
  margin-right: 10px;
}

.AlarmQuery .pagination-area {
  position: absolute;
  width: 100%;
  height: 32px;
  bottom: 0px;
  background-color: #eeeeee;
}

.AlarmQuery .el-table-redefine {
  width: 100%;
  height: 100%;
  /* display: flex;
  flex-flow: column; */
}

.AlarmQuery .el-table-redefine .el-table__body-wrapper {
  /* overflow: hidden;
  overflow-y: auto;
  flex-grow: 1; */
}

.AlarmQuery .el-dialog {
  background-color: rgb(215, 239, 236);
  padding-bottom: 5px;
}
.AlarmQuery .confirm_dialog .el-dialog__header {
  padding: 0px 5px;
}
.AlarmQuery .confirm_dialog .el-dialog__header .el-dialog__title {
  font-size: 13px;
}
.AlarmQuery .confirm_dialog .el-dialog__headerbtn {
  top: 3px;
  right: 10px;
}
.AlarmQuery .confirm_dialog .el-dialog__body {
  border: 1px solid #90e8c6;
  background-color: white;
  margin: 0px 5px;
  padding: 0px;
}
.AlarmQuery .confirm_dialog .dialog-body .body-title {
  margin: 20px 10px;
}
.AlarmQuery .confirm_dialog .dialog-footer {
  display: block;
  text-align: center;
  margin-bottom: 20px;
}
.AlarmQuery .confirm_dialog .dialog-footer .el-button {
  padding: 5px 25px;
  margin-top: 5px;
  font-size: 13px;
}
.AlarmQuery .return-backgorund {
  background: linear-gradient(
    rgb(227, 242, 238),
    rgb(202, 231, 238)
  ); /* 标准的语法 */
}
.AlarmQuery .return-backgorund-hidden {
  display: none;
}
.AlarmQuery .return-button {
  color: black;
  margin-left: 5px;
  font-size: 14px;
}
</style>